/**
 * 设备类型
 * @return {[type]} [description]
 */
import universalFetch, { handleFetchError } from 'store/modules/fetch'

const getDeviceType = (callback) => {
  universalFetch(`${__SERVICE_API__}device/dicts/device-types`)
  .then((res) => res.json())
  .then((json) => callback(json))
  .catch((error) => {
    console.error(error)
  })
}

/**
 * 设备型号
 * @param  {[type]} type [description]
 * @return {[type]}      [description]
 */
const getSpecs = (type, callback) => {
  let url = `${__SERVICE_API__}device/dicts/specs`
  if (type) {
    url += `?type=${type}`
  }
  universalFetch(url)
  .then((res) => res.json())
  .then((json) => callback(json))
  .catch((error) => {
    console.error(error)
  })
}

export {
  getSpecs,
  getDeviceType
}
